﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package Modules.franchise.transactions {
    import Engine.Transactions.*;
    import Display.*;
    import Classes.inventory.*;
    import Modules.franchise.data.*;

    public class TFinalizeFranchisePendingName extends Transaction {

        private var m_franchiseType:String;
        private var m_legalFranchiseName:String = null;

        public function TFinalizeFranchisePendingName(_arg1:String){
            this.m_franchiseType = _arg1;
            var _local2:OwnedFranchiseData = Global.franchiseManager.getFranchise(_arg1);
            if (_local2){
                this.m_legalFranchiseName = _local2.franchiseName;
                Global.franchiseManager.model.setFranchiseName(_local2.pendingName, _arg1);
                Global.franchiseManager.model.setPendingName(null, _arg1);
                Global.player.requestInventory.removeItem(RequestItemType.SIGNATURE, Global.franchiseManager.getSignatureCount(_arg1), _arg1);
            };
        }
        override public function perform():void{
            signedCall("FranchiseService.finalizeFranchisePendingName", this.m_franchiseType);
        }
        override protected function onComplete(_arg1:Object):void{
            var _local2:OwnedFranchiseData;
            if (_arg1["result"] == INVALID_DATA){
                UI.displayMessage(ZLoc.t("Dialogs", "InvalidFranchiseName"));
                _local2 = Global.franchiseManager.getFranchise(this.m_franchiseType);
                if (_local2){
                    if (this.m_legalFranchiseName){
                        Global.franchiseManager.model.setFranchiseName(this.m_legalFranchiseName, this.m_franchiseType);
                    };
                };
            };
        }

    }
}//package Modules.franchise.transactions 
